<?php include '../public/header.php' ?>
<?php include '../public/header_index.php' ?>
<body class="laytp-container">
<div id="opt_nav">
</div>

<div class="layui-card" id="search-form">
    <div class="layui-card-body">
        <form class="layui-form" id="TableSearchFormId" lay-filter="TableSearchForm" onkeydown="keyTableSearch('TableSearchForm', 'datalist')">
            <div class="layui-form-item">
                <div class="layui-row">
                    <div class="layui-col-md3">
                        <label class="layui-form-label">所属单位</label>
                        <div class="layui-input-block">
                            <div id="chanid" class="xmselect_div">
                                <div class="xmselect_title">请选择</div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">账户：</label>
                        <div class="layui-input-block">
                            <select id="accid" name="accid" lay-filter="accid">
                                <option value="">请选择</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">年份：</label>
                        <div class="layui-input-block">
                            <select id="year" name="year" lay-filter="year">
                                <option value="">请选择</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <div class="layui-form-item search-div">
                            <div class="layui-form-item layui-inline">
                                <button class="laytp-btn laytp-btn-md laytp-btn-primary" id="TableSearchButton" type="button"><i class="layui-icon layui-icon-search"></i>查询</button>
                                <button class="layui-btn layui-btn-primary" onclick="listTableReset()" id="TableSearchReset" type="reset" ><i class="layui-icon layui-icon-refresh"></i>重置</button>
<!--                                <div id="search_open" onclick="toggle_search()">-->
<!--                                    <i class="layui-icon layui-icon-down"></i>展开-->
<!--                                </div>-->
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>

<div class="layui-card" id="table-card">
    <div class="layui-card-body">
        <div class="layui-row">
            <div class="layui-col-md12" id="table_list">
                <div class="layui-card-body">
                    <table id="datalist" lay-filter="datalist"></table>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/html" id="test-dropdown-toolbar-barDemo">

</script>
<script type="text/html" id="toolbarDemo">
    <div class = "layui-btn-container">
    </div>
</script>
<script>


    layui.use(["laytp",'laypage','table','dropdown','form','soulTable'], function () {
        var laypage = layui.laypage, table = layui.table, dropdown = layui.dropdown, form = layui.form, soulTable = layui.soulTable;

        $('#TableSearchReset').click(function () {
            $('.xmselect_div>xm-select').find('.xm-label-block').css('display','none');
            $('.xmselect_div').append('<div class="xmselect_title">请选择</div>');
            searchTableFunc(form, table)
        });

        setSouTableExport('公司年度收支汇总');
        var mytable = table.render({
            elem: "#datalist",id: "datalist"
            ,url: facade.url(ask_com_year_shu),where: {}, page: true, height: 'full-140'
            ,soulSort: TabInit.soulSort,method: TabInit.method, toolbar: TabInit.toolbar, overflow: TabInit.overflow
            ,defaultToolbar: TabInit.defaultToolbar,filter: TabInit.filter
            ,request: TabInit.request,response: TabInit.response,contextmenu:get_table_contextmenu(soulTable)
            ,text: TabInit.text,totalRow: true
            ,parseData: function (res) {
                xmselect_dan('chanid', res.data.chanid, res.data.is_chanid, function (res) {
                    setTimeout(function () {
                        searchTableFunc(form, table);
                    },100)
                })
                xiala_zhan_one_you('year', res.data.year, res.data.is_year)
                xiala_zhan_two('accid', res.data.accid, res.data.is_accid,'id','name')

                render_from();
                return {
                    "code": res.code,
                    "msg": res.message,
                    "count": res.data.total,
                    "data": res.data.data
                };
            }
            , cols: [[
                {type: "checkbox", fixed: 'left',rowspan:2}
                ,{type:'numbers',title:'序号',totalRowText: '合计',fixed:'left',rowspan:2}
                ,{field: 'year', title: '年度',rowspan:2}
                ,{field: 'monthname', title: '月份',rowspan:2}
                ,{field: '', title: '收入(元)',colspan:4,align:'center'}
                ,{field: '', title: '支出(元)',colspan:8,align:'center'}
                ,{field:'shouzhicha',title:'收支差(元)',rowspan:2,totalRow: true,align:'right',templet: function(d){
                        if(d.shouzhicha < 0){
                            return '<span class="colorhong">'+parseFormatNum(d.shouzhicha)+'</span>';
                        }else{
                            return '<span class="">'+parseFormatNum(d.shouzhicha)+'</span>';
                        }
                    }}
            ],
            [
                {field:'shou_tou',title:'投标费收取',totalRow: true,align:'right',event: 'shou_tou',templet: function(d){return '<span class="colorlan">'+parseFormatNum(d.shou_tou)+'</span>';}}
                ,{field:'shou_xiang',title:'项目收款',totalRow: true,align:'right',event: 'shou_xiang',templet: function(d){return '<span class="colorlan">'+parseFormatNum(d.shou_xiang)+'</span>';}}
                ,{field:'shou_qi',title:'其他收款',totalRow: true,align:'right',event: 'shou_qi',templet: function(d){return '<span class="colorlan">'+parseFormatNum(d.shou_qi)+'</span>';}}
                ,{field:'shou_all',title:'收入合计',totalRow: true,align:'right',templet: function(d){return '<span class="">'+parseFormatNum(d.shou_all)+'</span>';}}

                ,{field:'zhi_tou',title:'投标费支付',totalRow: true,align:'right',event: 'zhi_tou',templet: function(d){return '<span class="colorlan">'+parseFormatNum(d.zhi_tou)+'</span>';}}
                ,{field:'zhi_xiang',title:'项目付款',totalRow: true,align:'right',event: 'zhi_xiang',templet: function(d){return '<span class="colorlan">'+parseFormatNum(d.zhi_xiang)+'</span>';}}
                ,{field:'zhi_enbao',title:'项目费用报销',totalRow: true,align:'right',event: 'zhi_enbao',templet: function(d){return '<span class="colorlan">'+parseFormatNum(d.zhi_enbao)+'</span>';}}
                ,{field:'zhi_jintui',title:'进项退税',totalRow: true,align:'right',event: 'zhi_jintui',templet: function(d){return '<span class="colorlan">'+parseFormatNum(d.zhi_jintui)+'</span>';}}
                ,{field:'zhi_lianjie',title:'联营结算',totalRow: true,align:'right',event: 'zhi_lianjie',templet: function(d){return '<span class="colorlan">'+parseFormatNum(d.zhi_lianjie)+'</span>';}}
                ,{field:'zhi_dayfu',title:'日常付款',totalRow: true,align:'right',event: 'zhi_dayfu',templet: function(d){return '<span class="colorlan">'+parseFormatNum(d.zhi_dayfu)+'</span>';}}
                ,{field:'zhi_daybao',title:'日常费用报销',totalRow: true,align:'right',event: 'zhi_daybao',templet: function(d){return '<span class="colorlan">'+parseFormatNum(d.zhi_daybao)+'</span>';}}
                ,{field:'zhi_all',title:'支出合计',totalRow: true,align:'right',templet: function(d){return '<span class="">'+parseFormatNum(d.zhi_all)+'</span>';}}
            ]]
            , done: function (res) {
                soulTable.render(this);
            }
        });

        table.on('tool(datalist)',function (obj) {
            var data = obj.data;
            if(obj.event === 'shou_tou'){
                openNavPage('查看交易明细信息','account_list/index.php?chanid='+data.id+'&modtype=1&dt='+data.dt_month+'&acc_name='+encodeURIComponent(data.acc_name));
            }
            if(obj.event === 'shou_xiang'){
                openNavPage('查看交易明细信息','account_list/index.php?chanid='+data.id+'&modtype=2&dt='+data.dt_month+'&acc_name='+encodeURIComponent(data.acc_name));
            }
            if(obj.event === 'shou_qi'){
                openNavPage('查看交易明细信息','account_list/index.php?chanid='+data.id+'&modtype=4&dt='+data.dt_month+'&acc_name='+encodeURIComponent(data.acc_name));
            }

            if(obj.event === 'zhi_tou'){
                openNavPage('查看交易明细信息','account_list/index.php?chanid='+data.id+'&modtype=21&dt='+data.dt_month+'&acc_name='+encodeURIComponent(data.acc_name));
            }
            if(obj.event === 'zhi_xiang'){
                openNavPage('查看交易明细信息','account_list/index.php?chanid='+data.id+'&modtype=22&dt='+data.dt_month+'&acc_name='+encodeURIComponent(data.acc_name));
            }
            if(obj.event === 'zhi_enbao'){
                openNavPage('查看交易明细信息','account_list/index.php?chanid='+data.id+'&modtype=23&dt='+data.dt_month+'&acc_name='+encodeURIComponent(data.acc_name));
            }
            if(obj.event === 'zhi_jintui'){
                openNavPage('查看交易明细信息','account_list/index.php?chanid='+data.id+'&modtype=24&dt='+data.dt_month+'&acc_name='+encodeURIComponent(data.acc_name));
            }
            if(obj.event === 'zhi_lianjie'){
                openNavPage('查看交易明细信息','account_list/index.php?chanid='+data.id+'&modtype=25&dt='+data.dt_month+'&acc_name='+encodeURIComponent(data.acc_name));
            }
            if(obj.event === 'zhi_dayfu'){
                openNavPage('查看交易明细信息','account_list/index.php?chanid='+data.id+'&modtype=28&dt='+data.dt_month+'&acc_name='+encodeURIComponent(data.acc_name));
            }
            if(obj.event === 'zhi_daybao'){
                openNavPage('查看交易明细信息','account_list/index.php?chanid='+data.id+'&modtype=27&dt='+data.dt_month+'&acc_name='+encodeURIComponent(data.acc_name));
            }
        });
        listTableSearch(form, table);
    });



</script>
</body>
</html>
